﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate;
using System.Windows.Forms;

namespace GeCo_MenuPrincipal
{
   
    public static class CSerialisation
    {
        private static string filename = AppDomain.CurrentDomain.BaseDirectory.Remove(AppDomain.CurrentDomain.BaseDirectory.IndexOf("bin")) + "Conteneur.xml";

        public static void Sauvegarder()
        {
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;

            using (XmlWriter writer = XmlWriter.Create(filename, settings))
            {
                IntermediateSerializer.Serialize(writer, Program.conteneur, null);
            }
        }

        public static void Charger()
        {
            using (FileStream stream = new FileStream(filename, FileMode.Open))
            {
                using (XmlReader reader = XmlReader.Create(stream))
                {
                    Program.conteneur = IntermediateSerializer.Deserialize<CConteneur>(reader, null);
                }
            }
            
        }  
    }
}
